#!/bin/sh
set -e

# 从环境变量读取配置，提供默认值（可选）
LISTEN_ADDR="${LISTEN_ADDR:-:9101}"
if [ -z "$INSTANCES" -o -z "$QUEUES" ]; then
  echo "Error: environment variable INSTANCES is not set."
  exit 1
fi

# 组装参数数组
ARGS="-listen $LISTEN_ADDR -instances $INSTANCES -queues $QUEUES"

echo "Starting httpsqs_exporter with args: $ARGS"

exec /app/httpsqs_exporter $ARGS
